<template>
  <div class="content-block">
    <div class="info-head">{{ title }}</div>
    <div class="info-content">
      <v-chart :option="chartOption" style="width:100%;height:300px;"></v-chart>
    </div>
  </div>
</template>

<script>
export default {
  name: 'bar-chart',
  props: ['title', 'unit'],
  data () {
    return {
      lines: ['电力热力', '煤炭', '炼焦', '造纸', '其他', '化学', '水泥', '橡胶']
    }
  },
  computed: {
    chartOption () {
      return {
        color: ['#50fdfc', '#e6b00e'],
        tooltip: {
          trigger: 'item'
        },
        grid: {
          left: '20%',
          right: '25%'
        },
        xAxis: {
          type: 'value',
          name: this.unit,
          axisLine: {
            lineStyle: {
              color: '#2b7ed6',
            }
          },
          splitLine: {
            lineStyle: {
              color: '#024287',
            }
          },
          axisLabel: {
            color: '#6b92b5',
          },
        },
        yAxis: {
          type: 'category',
          data: this.lines,
          axisLine: {
            lineStyle: {
              color: '#2b7ed6',
            }
          },
          axisLabel: {
            color: '#6b92b5',
          },
        },
        series: {
          type: 'bar',
          showBackground: true,
          data: this.lines.map(() => Math.round(Math.random() * 99 + 1)).sort()
        }
      }
    }
  }
}
</script>

<style scoped>

</style>
